package com.yzc35326.typeapp

import android.content.Context
import android.widget.Toast
import java.io.*

object Util {
    const val TAG="Util"
    var oldName:String=""
    fun createFile(context: Context,content:String){
        val openFileOutput = context.openFileOutput("1.txt", Context.MODE_PRIVATE)
        val osw=BufferedWriter(OutputStreamWriter(openFileOutput,"UTF-8"))
        osw.write(content)
        osw.close()
    }

    @Throws(Exception::class)
    fun readFile(context: Context,path:String):BufferedReader{
        try{
            val openFileInput = FileInputStream(File(path))
            val osw= BufferedReader(InputStreamReader(openFileInput,"UTF-8"))
            return osw
        }catch (e:Exception){
            throw e
        }
    }
}